# Make ZITADEL locally accessible
# kubectl port-forward svc/my-zitadel 8080

# username: zitadel-admin@zitadel.localhost
# password: Password1!

# kubectl get secret zitadel-admin-sa -o jsonpath='{ .data.zitadel-admin-sa\.json }' | base64 --decode

export namespace="iam-system"
export app_name="zitadel"
export db_name="db"
export repo="zitadel"
export helm="$repo/$app_name"
export db_helm="bitnami/postgresql"
export url="https://charts.zitadel.com"
export tag=$(curl -sL https://api.github.com/repos/zitadel/zitadel/releases | jq -r ".[0].name")
# export tag="v4.1.3"
echo "Using ZITADEL version: $tag"

# helm repo remove $repo
helm repo add $repo $url
helm repo update $repo

# helm search repo zitadel/zitadel --devel --versions
helm upgrade --create-namespace --install \
 	-n $namespace $db_name $db_helm \
 	-f pg_values.yaml --devel

helm upgrade --create-namespace --install \
	-n $namespace $app_name $helm \
	--set image.tag="$tag" \
	--set login.image.tag="$tag" \
	-f zitadel_values.yaml --devel

# zitadel-admin@zitadel.iam.youling.io
# Password1!

# https://iam.youling.io/ui/console?login_hint=zitadel-admin@zitadel.iam.youling.io
